
'use strict';
import { inject, injectable } from 'inversify';
import { IWorkspaceService } from '../../common/application/types';
import '../../common/extension';
import { IPlatformService } from '../../common/platform/types';
import { IProcessServiceFactory } from '../../common/process/types';
import { ITerminalHelper } from '../../common/terminal/types';
import { ICurrentProcess, IDisposable, Resource } from '../../common/types';
import { InMemoryCache } from '../../common/utils/cacheUtils';
import { IEnvironmentVariablesProvider } from '../../common/variables/types';
import { EQEnvironment } from '../../eqEnvironments/info';
import { IInterpreterService } from '../contracts';
import { IEnvironmentActivationService } from './types';

export class EnvironmentActivationServiceCache {
  private static useStatic = false;
  private static staticMap = new Map<string, InMemoryCache<NodeJS.ProcessEnv | undefined>>();
  private normalMap = new Map<string, InMemoryCache<NodeJS.ProcessEnv | undefined>>();

  
  public clear() {
    // Don't clear during a test as the environment isn't going to change
    if (!EnvironmentActivationServiceCache.useStatic) {
        this.normalMap.clear();
    }
}
}
@injectable()
export class EnvironmentActivationService implements IEnvironmentActivationService, IDisposable {
    private readonly disposables: IDisposable[] = [];
    private readonly activatedEnvVariablesCache = new EnvironmentActivationServiceCache();
    constructor(
        @inject(ITerminalHelper) private readonly helper: ITerminalHelper,
        @inject(IPlatformService) private readonly platform: IPlatformService,
        @inject(IProcessServiceFactory) private processServiceFactory: IProcessServiceFactory,
        @inject(ICurrentProcess) private currentProcess: ICurrentProcess,
        @inject(IWorkspaceService) private workspace: IWorkspaceService,
        @inject(IInterpreterService) private interpreterService: IInterpreterService,
        @inject(IEnvironmentVariablesProvider) private readonly envVarsService: IEnvironmentVariablesProvider,
    ) {
        this.envVarsService.onDidEnvironmentVariablesChange(
            () => this.activatedEnvVariablesCache.clear(),
            this,
            this.disposables,
        );

        this.interpreterService.onDidChangeInterpreter(
            () => this.activatedEnvVariablesCache.clear(),
            this,
            this.disposables,
        );
    }
    public dispose(): void {
      this.disposables.forEach((d) => d.dispose());
  }
  getActivatedEnvironmentVariables(resource: Resource, interpreter?: EQEnvironment, allowExceptions?: boolean): Promise<NodeJS.ProcessEnv | undefined> {
    throw new Error('10Method not implemented.');
  }
  getEnvironmentActivationShellCommands(resource: Resource, interpreter?: EQEnvironment): Promise<string[] | undefined> {
    throw new Error('11Method not implemented.');
  }
  }

